/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once


#include "底层绘图/底层绘图框架.h"
#include "../引擎枚举数据.h"


//S_纹理*	f_创建纹理(E_绘图API 后端, ivec2 size, E_纹理格式 格式);
//S_结构对象指针 f_创建纹理(ivec3 size, E_纹理格式 格式);
S_纹理采样器* f_tex_创建纹理采样器(S_设备环境& ctx, S_纹理采样器创建参数 参数 = { E_纹理拉伸方式::e_边框, E_纹理拉伸方式::e_边框, E_纹理拉伸方式::e_边框 });
S_纹理采样器* f_tex_创建阴影纹理采样器(S_设备环境& ctx, S_纹理采样器创建参数 参数 = { E_纹理拉伸方式::e_边缘, E_纹理拉伸方式::e_边缘, E_纹理拉伸方式::e_边缘 });
S_纹理采样器* f_tex_创建颜色纹理采样器(S_设备环境& ctx);
S_纹理采样器* f_tex_创建平铺纹理采样器(S_设备环境& ctx);

void	f_tex_销毁纹理采样器(S_纹理采样器* 采样器);
void	f_tex_安装纹理采样器(S_纹理* tex, S_纹理采样器* sample);


EngineAPI_EXPORT S_纹理* f_tex_创建帧缓存纹理(S_设备环境& ctx, uvec3 size, E_纹理格式 格式, E_纹理维度类型 类型, E_MS次数 采样 = E_MS次数::e_MS_1, E_纹理排列 平铺方式 = E_纹理排列::e_瓦片, uint32 层 = 1);


EngineAPI_EXPORT void f_tex_setSize(S_纹理* tex, uvec2 newSize);



EngineAPI_EXPORT S_纹理* f_fromFile创建纹理(S_设备环境& ctx, S_纹理采样器* sample, std::string path);
EngineAPI_EXPORT S_纹理* f_fromFile创建纹理数组(S_设备环境& ctx, S_纹理采样器* sample, std::vector<std::string> path);

EngineAPI_EXPORT std::vector<S_纹理*> f_tex_从文件创建纹理(S_设备环境& ctx, S_纹理采样器* sample, const std::vector<std::filesystem::path>& path);

EngineAPI_EXPORT void	f_tex_从文件加载纹理到显卡(S_纹理* tex, std::string path, S_结构指针 命令缓存);

EngineAPI_EXPORT void	f_tex_保存到文件(S_纹理* tex, std::string path, S_结构指针 命令缓存 = nullptr);


EngineAPI_EXPORT void	f_tex_加载图像文件(S_纹理添加列队& path);
EngineAPI_EXPORT void	f_tex_加载图像到GPU(S_纹理添加列队& path, S_结构指针 命令缓存);
EngineAPI_EXPORT void	f_tex_从文件填充纹理(S_纹理* tex, std::string path, S_子集绘图命令* 绘图命令);
EngineAPI_EXPORT void	f_tex_从文件加载纹理(S_纹理* tex, const S_Props& path, int32 通道数量 = 4);

EngineAPI_EXPORT void	f_tex_纹理上传到显卡(S_纹理* tex);

EngineAPI_EXPORT void	f_tex_纹理保存到文件(S_纹理* tex, const S_Props& path, const S_Props& 格式枚举, const S_Props& 保存方式);
EngineAPI_EXPORT void	f_tex_纹理写入到文件(S_纹理* tex, const std::string& path, const std::u16string& 格式, int32 通道数量, int32 位宽);
EngineAPI_EXPORT void	f_tex_重置2D纹理大小(S_纹理* s_tex, S_纹理* t_tex, uvec2 新大小);

EngineAPI_EXPORT void	f_tex_创建独立纹理视图(S_纹理* tex, bool 颜色);

EngineAPI_EXPORT void	f_tex_立方体纹理深度布局(S_纹理* tex, uint32 层 = 0);
EngineAPI_EXPORT void	f_tex_set纹理颜色附件布局(S_纹理* tex, uint32 层数量);
EngineAPI_EXPORT void	f_tex_set着色器采样布局(S_纹理* tex, uint32 层数量);
void f_tex_set帧写入布局(S_纹理* tex, uint32 层数量);


EngineAPI_EXPORT S_纹理集*	f_纹理集_创建(uint32 num = 0);
EngineAPI_EXPORT void		f_纹理集_销毁(S_纹理集* ts);

EngineAPI_EXPORT uint32	f_纹理集_add纹理(S_纹理集* ts, S_纹理* 纹理);
EngineAPI_EXPORT uint32	f_纹理集_find纹理(S_纹理集* ts, const S_纹理* 纹理);
EngineAPI_EXPORT uint32	f_纹理集_get数量(S_纹理集* ts);
EngineAPI_EXPORT void	f_纹理集_set纹理(S_纹理集* ts, S_纹理* 纹理, uint32 loc);
EngineAPI_EXPORT void	f_纹理集_rem纹理(S_纹理集* ts, S_纹理* 纹理);
EngineAPI_EXPORT void	f_纹理集_set数量(S_纹理集* ts, uint32 num);
EngineAPI_EXPORT void	f_纹理集_fill纹理(S_纹理集* ts, S_纹理** 纹理, uint32 num);

EngineAPI_EXPORT void f_纹理集_刷新所有纹理信息(S_纹理集* ts);

Inline void f_纹理集_fill纹理(S_纹理集* ts, std::vector<S_纹理*> 填充纹理) {
	f_纹理集_fill纹理(ts, 填充纹理.data(), 填充纹理.size());
}


S_纹理* f_纹理集_get纹理(S_纹理集* ts, uint32 loc);


S_GPU纹理参数槽 f_纹理槽_创建(uint32 num);
void			f_纹理槽_销毁(S_GPU纹理参数槽& 纹理槽);
void			f_纹理槽_设置纹理(S_GPU纹理参数槽& 纹理槽, S_纹理* tex, uint32 绑定位置, uint32 槽);
void			f_纹理槽_填充纹理集(S_GPU纹理参数槽& 纹理槽, uint32 num, S_纹理集** ts, uint32 bindID);
void			f_纹理槽_设置纹理集(S_GPU纹理参数槽& 纹理槽, S_纹理集* 纹理集, uint32 loc, uint32 bindID);
void			f_纹理槽_更新纹理集(S_GPU纹理参数槽& 纹理槽, uint32 num, S_纹理集** 纹理集);






